package main

import (
	"fmt"
	"go_code/chatroom/client/process"
	"os"
)

func main() {
	for {
		var key int8
		var userId int64
		var username string
		var password string

		fmt.Println("--------欢迎登录多人聊天系统--------")
		fmt.Println("\t", "1 登录聊天系统")
		fmt.Println("\t", "2 注册用户")
		fmt.Println("\t", "3 退出系统")
		fmt.Println("请选择（1-3）：")
		fmt.Println("------------------------------------")

		_, _ = fmt.Scanf("%d\n", &key)

		switch key {
		case 1:
			fmt.Println("请输入用户 ID：")
			_, _ = fmt.Scanf("%d\n", &userId)
			fmt.Println("请输入密码：")
			_, _ = fmt.Scanf("%s\n", &password)
			userProcess := &process.UserProcess{
				Conn: conn,
			}
			_ = userProcess.Login(userId, password)
		case 2:
			fmt.Println("请输入用户 ID：")
			_, _ = fmt.Scanf("%d\n", &userId)
			fmt.Println("请输入用户名：")
			_, _ = fmt.Scanf("%s\n", &username)
			fmt.Println("请输入密码：")
			_, _ = fmt.Scanf("%s\n", &password)
			userProcess := &process.UserProcess{
				Conn: conn,
			}
			_ = userProcess.Register(userId, username, password)
		case 3:
			fmt.Println("退出成功")
			os.Exit(0)
		default:
			fmt.Println("输入有误，请重新选择")
		}
	}
}
